﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Nb.Schedules.Libs.Domains
{
    [TestClass]
    public class ScheduleTemplateTest
    {
        [TestMethod]
        public void CreateDailyTemplate_Should_Success()
        {
            var start = new DateTime(2000, 1, 1, 8, 0, 0);
            var end = new DateTime(2000, 1, 1, 18, 0, 0);

            var scheduleTemplate = ScheduleTemplate.CreateDailyTemplate("ADailyTemplate", start, end, 45, 15);
            Assert.AreEqual(10, scheduleTemplate.ScheduleTemplateItems.Count);
        }

        [ExpectedException(typeof(InvalidOperationException))]
        [TestMethod]
        public void CreateDailyTemplate_Bad_Date_Should_Fail()
        {
            var start = new DateTime(2000, 1, 1, 8, 0, 0);
            var end = new DateTime(2000, 1, 2, 18, 0, 0);
            ScheduleTemplate.CreateDailyTemplate("ADailyTemplate", start, end, 45, 15);
        }

        [ExpectedException(typeof(InvalidOperationException))]
        [TestMethod]
        public void CreateDailyTemplate_Bad_Hour_Should_Fail()
        {
            var start = new DateTime(2000, 1, 1, 8, 0, 0);
            var end = new DateTime(2000, 1, 2, 6, 0, 0);
            ScheduleTemplate.CreateDailyTemplate("ADailyTemplate", start, end, 45, 15);
        }

        [ExpectedException(typeof(InvalidOperationException))]
        [TestMethod]
        public void CreateDailyTemplate_Bad_Name_Should_Fail()
        {
            var start = new DateTime(2000, 1, 1, 8, 0, 0);
            var end = new DateTime(2000, 1, 2, 18, 0, 0);
            ScheduleTemplate.CreateDailyTemplate("", start, end, 45, 15);
        }


        [ExpectedException(typeof(InvalidOperationException))]
        [TestMethod]
        public void CreateDailyTemplate_CourseMinutes_LessThen30_Should_Fail()
        {
            var start = new DateTime(2000, 1, 1, 8, 0, 0);
            var end = new DateTime(2000, 1, 1, 18, 0, 0);
            ScheduleTemplate.CreateDailyTemplate("ADailyTemplate", start, end, 25, 15);
        }
    }
}
